import { NavBar } from 'antd-mobile'
import axios from 'axios';
import React, { useEffect, useState } from 'react'
import { useLocation, useNavigate } from 'react-router-dom'
import ListItem from '../../components/ListItem';

function List() {
    const {state}=useLocation();
    const navigate=useNavigate();
    const [list,setList]=useState([]);
    const getList=async()=>{
        const res=await axios.post('/api/trip/train',state)
        console.log(res.data.data)
        setList(res.data.data)
    }
    useEffect(()=>{
        getList()
    },[])
  return (
    <div>
      <NavBar onBack={()=>navigate(-1)}>{state.start}-{state.end}</NavBar>
      <div>
        {
            list.map((v,i)=>{
                return <ListItem key={i} v={v}></ListItem>
            })
        }
      </div>
    </div>
  )
}

export default List
